<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<div id="time"></div>
		<div></div>
		<div></div>
		<button>点击时间停止</button>
	</body>
	<script type="text/javascript">
				var timestamp1 = Date.parse(new Date());
				console.log(timestamp1)
				var timestamp2 = (new Date()).valueOf();
				console.log(timestamp2)
				var timestamp3 = new Date().getTime();
				console.log(timestamp3);
				var newdata = new Date(timestamp1)
				console.log(newdata)
				var mm = newdata.getMonth() + 1;
				mm = (mm < 10) ? "0" + mm:mm; 
				console.log(mm)  
		function getDate() {
			var newdate = new Date();
			var yy = newdate.getFullYear();
			var mm = newdate.getMonth() + 1;
			mm = addZore(mm)
			var dd = newdate.getDate();
			dd = addZore(dd)
			var hh = newdate.getHours();
			hh = addZore(hh)
			var ff = newdate.getMinutes();
			ff = addZore(ff)
			var ss = newdate.getSeconds();
			ss = addZore(ss)

			function addZore(hh) {
				hh = hh <= 9 ? "0" + hh : hh;
				return hh
			}
			return yy + "-" + mm + "-" + dd + "  " + hh + "-" + ff + "-" + ss;
		}

		var timer = setInterval(function() {
			var data = getDate();
			document.querySelector("#time").innerText = data
		}, 1000);
		var isclick = true;
		document.getElementsByTagName("button")[0].onclick = function() {
			if(isclick) {
				isclick = !isclick
				clearInterval(timer)
			} 

		}

		//第一种：获取的时间戳是把毫秒改成000显示，第二种和第三种是获取了当前毫秒的时间戳。
		//下面是把时间毫秒数转化为
	</script>

</html>